//
//  MusicDetailTableViewCell.m
//  OurRelaxDemo
//
//  Created by 王雅蓉 on 15/6/24.
//  Copyright (c) 2015年 于宾尧. All rights reserved.
//

#define cellForLine 1
#define collectionButton 50
#define songWidth 250
#define singerWidth 250

#import "MusicDetailTableViewCell.h"

@interface MusicDetailTableViewCell ()

@property (retain, nonatomic) UILabel *line;
@property (retain, nonatomic) UIButton *colButton;
@property (retain, nonatomic) UILabel *colLabel;

@property (retain, nonatomic) UILabel *songLabel;
@property (retain, nonatomic) UILabel *singerLabel;

@end

@implementation MusicDetailTableViewCell

-(void)dealloc
{
    [_line release];
    [_colButton release];
    [_colLabel release];
    [_songLabel release];
    [_singerLabel release];
    
    [_songList release];
    
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self createSubviews];
        self.songList = [[MusicForSonglist alloc] init];
        
    }
    return self;
}

-(void)createSubviews
{
    _line = [[UILabel alloc] initWithFrame:CGRectMake(collectionButton, 60 - cellForLine, 375 - collectionButton, cellForLine)];
    _line.backgroundColor = [UIColor lightGrayColor];
    _line.alpha = 0.5;
    [self.contentView addSubview:_line];
    [_line release];
    
    _colButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _colButton.frame = CGRectMake(10, 10, collectionButton - 25, collectionButton - 25);
    [_colButton setBackgroundImage:[UIImage imageNamed:@"musicCollection.jpg"] forState:UIControlStateNormal];
    [self.contentView addSubview:_colButton];
    [_colButton release];
    
    _colLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, _colButton.frame.origin.y + _colButton.frame.size.height, collectionButton - 10, self.frame.size.height - _colButton.frame.size.height - 5)];
    //_colLabel.backgroundColor = [UIColor cyanColor];
    _colLabel.textAlignment = NSTextAlignmentCenter;
    _colLabel.font = [UIFont systemFontOfSize:12.0];
    _colLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_colLabel];
    [_colLabel release];
    
    _songLabel = [[UILabel alloc] initWithFrame:CGRectMake(collectionButton + 10, 5, songWidth, 60 / 2 - 5)];
    //_songLabel.backgroundColor = [UIColor yellowColor];
    _songLabel.textColor = [UIColor darkGrayColor];
    [self.contentView addSubview:_songLabel];
    [_songLabel release];
    
    _singerLabel = [[UILabel alloc] initWithFrame:CGRectMake(_songLabel.frame.origin.x, _songLabel.frame.origin.y + _songLabel.frame.size.height + 2, _songLabel.frame.size.width, _songLabel.frame.size.height / 2 + 5)];
    //_singerLabel.backgroundColor = [UIColor redColor];
    _singerLabel.font = [UIFont systemFontOfSize:14.0];
    _singerLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_singerLabel];
    [_singerLabel release];
}

-(void)setSongList:(MusicForSonglist *)songList
{
    if (_songList != songList) {
        
        [_songList release];
        _songList = [songList retain];
        
    }
    //NSLog(@"=-=-=-=%@",songList.url_list);
    _songLabel.text = songList.song_name;
    _singerLabel.text = songList.singer_name;
    
    _colLabel.text = [songList.pick_count description];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
